#! /bin/sh

. /lib/lsb/init-functions

do_start()
{
	log_info_msg "Populating /dev with device nodes ..."
	if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
		log_failure_msg "Udev cannot start without @sysfs@"
		exit 2
	fi

	echo > /proc/sys/kernel/hotplug

	start_daemon -p /var/run/udev.pid \
		/lib/udev/udevd --daemon && \
		log_success_msg || log_failure_msg

	/sbin/udevadm trigger --action=add --type=subsystems
	/sbin/udevadm trigger --action=add --type=devices
	/sbin/udevadm settle
	if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi
}

do_stop()
{
	stop_daemon -p /var/run/udev.pid /lib/udev/udevd
}

case "$1" in
	start) do_start ;;
	stop) do_stop;;
	restart|reload) do_stop; do_start;;
	*) echo "Usage: $0 {start}"; exit 1;;
esac
